package com.dmbjz.demo;

import com.boot3.starter.annotation.EnableRobot;
import com.dmbjz.demo.config.TeacherConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

//开启配置文件属性绑定
@EnableConfigurationProperties
//指定要绑定的类的扫描路径,一般来说只有第三方包才会用到 @EnableConfigurationProperties 与 @ConfigurationPropertiesScan
@ConfigurationPropertiesScan(basePackages = "com.dmbjz")
@SpringBootApplication
//@EnableRobot
public class HelloDemoApplication {

    public static void main(String[] args) {

        // JDK 10 的局部变量写法
        var ioc = SpringApplication.run(HelloDemoApplication.class, args);

/*
        //获取Bean对象
        var names = ioc.getBeanDefinitionNames();
        for (String beanName : names) {
            System.out.println(beanName);
        }

        //根据获取Bean对象-Appconfig
        var cryptoArr = ioc.getBeanNamesForType(FastsqlException.class);
        for (String crypto : cryptoArr) {
            System.out.println(crypto);
        }

        //根据获取Bean对象-Appconfig2
        for (String student : ioc.getBeanNamesForType(Student.class)) {
            System.out.println(student);
        }

        //根据获取Bean对象-Appconfig2
        for (String user : ioc.getBeanNamesForType(User.class)) {
            System.out.println(user);
        }
*/

        //获取属性绑定案例
        TeacherConfig teacherConfig = ioc.getBean(TeacherConfig.class);
        System.out.println(teacherConfig);

    }

}
